# encoding: utf-8
""" 
@version: v1.0 
@author: autumner 
@license: Apache Licence  
@contact: 18322313385@163.com 
@site:  
@software: PyCharm 
@file: alice_wordcloud.py 
@time: 2018/8/13 13:49
"""
'''
利用wordcloud、jieba、scipy.misc生成一个alice形状词云
'''


from wordcloud import WordCloud
from scipy.misc import imread


mask = imread('alice.png')

with open('alicewonderland.txt') as f:
    txt = f.read()

wdcd = WordCloud(font_path='times.ttf',
                 background_color='white',
                 width=640,
                 height=460,
                 max_words=200,
                 max_font_size=80,
                 mask=mask,).generate(txt)

wdcd.to_file('aliceinwonderland.png')

